//
//  DSSettingViewModel.m
//  DSJY
//
//  Created by lx on 17/7/14.
//  Copyright © 2017年 dsjy. All rights reserved.
//  设置VM

#import "DSSettingViewModel.h"
#import "DSAccountViewModel.h"

@implementation DSSettingViewModel

#pragma mark - 初始化
- (instancetype)init
{
    if (self = [super init]) {
        //绑定事件
        [self initialBind];
    }
    return self;
}

- (void)initialBind
{
    _updateRankingCommand = [[RACCommand alloc] initWithSignalBlock:^RACSignal *(NSString *sharescore) {
        
        return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
            [DSNetworkTool updateSharescoreWithParams:[DSAccountViewModel sharedAccount].account sharescore:sharescore success:^(NSDictionary *responseObject) {
                //返回值
                self.response = [YQResponse mj_objectWithKeyValues:responseObject];
                [self veriResponse:self.response finishedCallBack:^{
                    [subscriber sendNext:nil];
                    [subscriber sendCompleted];
                }];
            } failure:^(NSError *error) {
                [SVProgressHUD showErrorWithStatus:@"设置分享排行榜的操作失败!"];
                [subscriber sendCompleted];
            }];
            return nil;
        }];
    }];
}

@end
